<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>个人推广设置</title>
    <link href="__PUBLIC__/home/css/bootstrap.min.css" rel="stylesheet">
    <link href="__PUBLIC__/home/css/alert.css" rel="stylesheet">
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <link href="__PUBLIC__/home/css/common.css" rel="stylesheet">
</head>

<body>
<div class="container-fluid">
    <!-- Page Heading -->
    <form class="form-inline" method="post" action="{:U('Promoters/index')}">
        <div class="form-group">
            <label for="exampleInputName2">姓名</label>
            <input type="text" class="form-control" id="exampleInputName2" placeholder="请输入姓名" name="user_name" value="{$user_name}">
        </div>
        <div class="form-group">
            <label for="exampleInputEmail2">手机号</label>
            <input type="text" class="form-control" id="exampleInputEmail2" placeholder="请输入手机号" name="phone_mob" value="{$phone_mob}">
        </div>
        <div class="form-group">
            <label for="exampleInputName2">状态</label>
            <select class="form-control" style="height: 35px;" name="status">
                <option value="0">请选择状态</option>
                <option value="1"<if condition="$status eq 1">selected</if> >正常</option>
                <option value="2"<if condition="$status eq 2">selected</if> >禁用</option>
            </select>
        </div>
        <button type="submit" class="btn btn-success">查询</button>
        <a href="{:U('Promoters/index')}" class="btn btn-warning">清空</a>
        <a href="{:U('Promoters/add')}" class="btn btn-primary">添加</a>
    </form>
    <div class="row">
        <div class="col-lg-12">
            <h2></h2>
            <div class="">
                <table class="table table-bordered table-hover table-striped" id="dataTables-date">
                    <thead>
                    <tr>
                        <th>编号</th>
                        <th>姓名</th>
                        <th>手机号</th>
                        <th>职务</th>
                        <th>添加时间</th>
                        <th>更新时间</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <volist name="list" id ="sto">
                        <tr>
                            <td>{$sto.id}</td>
                            <td>{$sto.user_name}</td>
                            <td>{$sto.phone_mob}</td>
                            <td>{$sto.post|default='无'}</td>
                            <td>{$sto.create_time|date="Y-m-d H:i",###}</td>
                            <td>
                                <if condition="$sto['update_time']">
                                    {$sto.update_time|date="Y-m-d H:i",###}
                                    <else/>
                                    无
                                </if>
                            </td>
                            <td>
                                <if condition="$sto.status eq 1">
                                    <a href="javascript:;" class="btn btn-success cancelStatus" data-id="{$sto.id}">正常</a>
                                    <elseif condition="$sto.status eq 2" />
                                    <a href="javascript:;" class="btn btn-danger confirmStatus" data-id="{$sto.id}">禁用</a>
                                </if>
                            </td>
                            <td>
                                <a type="button" class="btn btn-default" href="{:U('Promoters/edit',array('id'=>$sto['id']))}">编辑</a>
                                <a class="btn btn-danger delete" data-id="{$sto.id}" href="javescript:;{:U('Promoters/delete',array('id'=>$sto['id']))}">删除</a>
                                <a type="button" class="btn btn-success" href="{:U('Promoters/statistics',array('id'=>$sto['user_id']))}">查看邀请明细</a>
                            </td>
                        </tr>
                    </volist>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    <!-- /.row -->
    <div class="pages">
        {$page}
    </div>
</div>
<script src="__PUBLIC__/home/js/jquery.min.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="__PUBLIC__/home/js/bootstrap.min.js"></script>
<script src="__PUBLIC__/home/js/alert.js"></script>
<script src="__PUBLIC__/home/js/layer/layer.js"></script>
<!-- iframe自适应高度 -->
</body>
<script type="text/javascript">
    //禁用
    var url = "{:U('Promoters/updateStatus')}";
    $(".cancelStatus").click(function(){
        var id = $(this).attr('data-id');
        layer.confirm('您确定要禁用这个推广人员么？', {
            btn: ['是','否'] //按钮
        }, function(){
            $.post(url,{
                id:id,
                status:2
            },function(data){
                var res = JSON.parse(data);
                if(res.code == 1){
                    layer.msg(res.msg,function(){
                        window.location.reload();
                    });
                }else{
                    layer.msg('操作失败！');
                    return false;
                }
            })
        });
    });
    //正常
    $(".confirmStatus").click(function(){
        var id = $(this).attr('data-id');
        layer.confirm('您确定要启用这个推广人员么？', {
            btn: ['是','否'] //按钮
        }, function(){
            $.post(url,{
                id:id,
                status:1
            },function(data){
                var res = JSON.parse(data);
                if(res.code == 1){
                    layer.msg(res.msg,function(){
                        window.location.reload();
                    });
                }else{
                    layer.msg('操作失败！');
                    return false;
                }
            })
        });
    })
    //删除
    $(".delete").click(function(){
        var id = $(this).attr("data-id");
        var deleteUrl = "{:U('Promoters/delete')}";
        layer.confirm('您确定要删除这个推广人员么？', {
            btn: ['是','否'] //按钮
        }, function(){
            $.post(deleteUrl,{
                id:id,
            },function(data){
                var res = JSON.parse(data);
                if(res.code == 1){
                    layer.msg(res.msg,function(){
                        window.location.reload();
                    });
                }else{
                    layer.msg('操作失败！');
                    return false;
                }
            })
        });
    })

    //查看统计信息
    $(".detail").click(function(){
        var store_id = $(this).attr('data-id');
        var url = "{:U('Store/postData')}";
        $.post(url,{
            store_id:store_id
        },function(data){
            var res = JSON.parse(data);
            if(res.code == 1){
                $.each(res.list,function(index,item){

                })
                layer.open({
                    type: 1,
                    skin: 'layui-layer-rim', //加上边框
                    area: ['420px', '240px'], //宽高
                    content: 'html内容'
                });
            }else{
                layer.msg('暂无数据');
                return false;
            }
        })
    })
</script>

</html>
